﻿DECLARE @Var_YSName VARCHAR(100)
DECLARE @Var_KSCode VARCHAR(100)

SET @Var_YSName = @YSName_In
SET @Var_KSCode = @KSCode_In

SELECT CODE AS DoctCode,
       NAME AS DoctName, 
       KSCODE AS DeptCode,
       KSNAME AS DeptName,
       CASE YHFLAG WHEN 1 THEN '护士'
                   WHEN 2 THEN '普通医师(初职)'
                   WHEN 3 THEN '主任或专家(高职)'
                   WHEN 4 THEN '非医技人员'
                   WHEN 5 THEN '主治医师(中职)'
                   WHEN 6 THEN '副主任医师'
       END AS SessionType, 
       YSType AS DoctType,
       CASE WHEN DirectorFlag = 1 THEN '科室主任' END AS IsMaster
FROM dbo.YSCODE(NOLOCK)
WHERE NAME LIKE @Var_YSName AND KSCODE LIKE @Var_KSCode